#ifndef FRAGMENTDATABASE_H
#define FRAGMENTDATABASE_H

#include <map>
#include <set>
#include <vector>

#include <boost/shared_ptr.hpp>

#include <Klein/Shader/Fragment.h>
#include <Klein/Shader/Graph.h>
#include <Klein/Shader/Singleton.h>



class KLEIN_API FragmentDatabase : public Singleton<FragmentDatabase>
{
public:

	bool AddFragment(const FragmentRef& fragment);
	FragmentRef GetFragment(const FragmentIdentifier& fragmentIdentifier);
	void ActiveFragmentCategory(const String& fragmentCategoryName);
	const String& GetActivedFragmentCategoryName() const;
	void CollectFragmentCategoryNames(std::set<String>& categoryNames) const;
	void CollectFragmentClassNames(const String& categoryName, std::set<String>& fragmentClassNames) const;
	void CollectFragments(const String& fragmentCategoryClassName, std::vector<FragmentRef>& fragments) const;

private:

	std::map<String, FragmentRef> mNodes;

	String mActivedFragmentCategoryName;

	std::map<String, std::set<String> > mCategoryNamesToCategoryClassNames;
	std::map<String, std::set<String> > mCategoryClassNamesToNodeNames;
};

#endif
